#ifndef __UART_SELF_H__
#define __UART_SELF_H__

#include "main.h"

typedef void (*serial_recv_cb_t)(uint8_t *data, uint16_t data_len, void *user_data);

#ifdef __cplusplus
extern "C"
{
#endif

    typedef struct
    {
        UART_HandleTypeDef *uart_handle;
        serial_recv_cb_t recv_cb;
        void *user_data;
        uint16_t dma_buf_len;
        uint8_t *dma_buff;
    } serial_config_t;

    typedef serial_config_t uart_t;

    HAL_StatusTypeDef serial_init(serial_recv_cb_t recv_cb, void *user_data);
    void serial_send_with_len(const char *str, uint16_t len);
    void serial_send(const char *str);
    void serial_send_char(char ch);

    HAL_StatusTypeDef uart_recv_register(serial_config_t *config);


#ifdef __cplusplus
}
#endif
#endif
